<!DOCTYPE html>
<html>
    <head>
        <title>VTV Vote</title>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0">
        <meta name="apple-mobile-web-app-capable" content="yes">
        <meta name="apple-mobile-web-app-status-bar-style" content="black">
        <meta name="format-detection" content="telephone=no">
        <link rel="stylesheet" type="text/css" href="public/css/style.css"/>
    </head>
    <body>
        <div id="UI_InfoBar">
            <div class="Inner">
                <div id="Wait_Infobar" class="Wait"><div class="Wait_inner"></div></div>
            </div>
        </div>
        <div id="UI_Page">
            <div id="page_indexindex" class="page_item"></div>
            <div id="page_indexstatistic" class="page_item"></div>
            <div id="page_indexhome" class="page_item page_active"></div>

            <div class="UI_PopupPanel">
                <div class="Inner">
                    <div class="Body">
                        <div class="Scroller">
                            <div class="Scroll_Inner"></div>
                        </div>
                        <div id="Wait_PopupPanel" class="Wait"><div class="Wait_inner"></div></div>
                    </div>
                </div>
            </div>

            <div class="UI_TextPanel">
                <div class="Inner">
                    <div class="Body">
                        <div class="center">
                            <a class="clearText"></a>
                            <textarea placeholder="Ý kiến của bạn..."></textarea>
                            <button class="Panel_Submit">Gửi đi</button>
                            <button class="Panel_Cancel">Đóng lại</button>
                        </div>
                    </div>
                </div>
            </div>

        </div>

        <script type="text/javascript" src="public/js/jquery-2.0.2.min.js"></script>
        <script type="text/javascript" src="public/js/jquery.tap.min.js"></script>
        <script type="text/javascript" src="public/js/spin.min.js"></script>
        <script type="text/javascript" src="app/app.js"></script>
        <script type="text/javascript" src="appcode/Ui.js"></script>
        <script type="text/javascript" src="appcode/Appcode.js"></script>

        <script type="text/javascript" src="appcode/Tvshow.js"></script>

        <script type="text/javascript" src="public/js/idangerous.swiper-2.0.min.js"></script>
        <script type="text/javascript">
            $(function () {
                $.ajaxSetup({async: true, cache: false});
                _this.appName = "vtvnow";
                 
                /*_this.Base_Url = "http://125.212.192.114/VTVDEV/";
                 _this.Base_Api = "http://125.212.192.114/VTVDEV/api/";
                 _this.Base_Upload = "http://125.212.192.114/VTVDEV/data/";
        
                 _this.Base_Url = "http://vtvnow.vtvdigitalcenter.vn/test/";
                 _this.Base_Api = "http://vtvnow.vtvdigitalcenter.vn/test/api/";
                 _this.Base_Upload = "http://vtvnow.vtvdigitalcenter.vn/test/data/"*/
                
                _this.Base_Url = "http://vtvnow.vtvdigitalcenter.vn/";
                _this.Base_Api = "http://vtvnow.vtvdigitalcenter.vn/vtvnowapi/";
                _this.Base_Upload = "http://vtvnow.vn/data/";

                _this.setAppVersion = {
                    ios: "1.1.1",
                    android: "1.1.6"
                };
                _this.appConfirmUpdate(function () {
                    setTimeout(function () {
                        User.confirmLogin();
                    }, 3000);
                });

                TextPanel.init();
                new Spinner(_this.uiWaitOptions).spin(document.querySelector('#Wait_Infobar .Wait_inner'));

                /*
                 *@Load menu lần đầu
                 */

                PopupPanel.open();
                $(".UI_PopupPanel").addClass("hide");
                setTimeout(function () {
                    List.gets(function () {
                        setTimeout(function () {
                            PopupPanel.close();
                            $(".UI_PopupPanel").removeClass("hide");
                        }, 3000);
                    }, function () {
                        PopupPanel.close();
                    });
                }, 500);


                Toast.notification({text: "Chọn chương trình", top: 18, left: 15}); //Khởi tạo hướng dẫn dùng list show

                //_this.loadJs("plugins/" + _this.appOs + "/cordova.js");
                //_this.loadJs("plugins/" + _this.appOs + "/plugins.js");
                var FirstTime = true;
                _this.loadJs("public/js/socket.io-1.2.0.js", function () {

                    new SocketConnection(function (socketUrl) {

                        socket = io.connect(socketUrl); //, {'force new connection': true}
                        socket.on("connect", function () {
                            //console.log("Connected: " + socketUrl);
                            if (FirstTime) {
                                FirstTime = false;
                            } else {
                                socket.emit('jointvshow', Program.id_tvshow, User.id);
                                socket.emit('connecttwo', Program.id_tvshow);
                                Statistic.initData();
                            }
                        });
                        socket.on("disconnect", function () {
                            //console.log("/******** Disconnected *********/");
                            socket.io.connect();
                        });
                        socket.on('status_show', function (status) {
                            //console.log("status_show " + Program.id_tvshow + ": " + status);
                            if (status == 1) {//Chương trình chưa kết thúc
                                Program.is_stopped = false;

                            } else {//Chương trình đã kết thúc
                                Program.is_stopped = true;
                            }
                        });
                        Program.runSocket();
                    });
                });
            });
        </script>
    </body>
</html>